<template>
  <div id="app">
    <router-view/>
  </div>
</template>
<script>

    export default {
        name: 'app',
      data() {
          return {
            keyWords:[]
          }
      },
        mounted(){
        this.goDifren()
          this.getKeyWord()
            function checkIE(){
                return '-ms-scroll-limit' in document.documentElement.style && '-ms-ime-align' in document.documentElement.style
            }
            if (checkIE()) {
                window.addEventListener('hashchange', () => {
                    var currentPath = window.location.hash.slice(1);
                if (this.$route.path !== currentPath) {
                    this.$router.push(currentPath)
                }
            }, false)
            }
          this.$router.afterEach((to, from, next) => {
            window.scrollTo(0, 0)
          })
        },
      methods:{
          getKeyWord() {
            this.$http.post(this.API.get_keyword).then((res) => {
              if(res.status ===200 && res.data.length>0){
                res.data.forEach((item) => {
                  this.keyWords.push(item.keyword)
                })
              }
              let meta = document.querySelector('#metaKey');
              let metaDis = document.querySelector('#metaDis');
              meta.content =this.keyWords.join(",");
              metaDis.content =this.keyWords.join(",");
            })
          },
        IsPC() {
          let userAgentInfo = navigator.userAgent;
          let Agents = ["Android", "iPhone",
            "SymbianOS", "Windows Phone", "iPod"];
          let flag = true;
          for (let v = 0; v < Agents.length; v++) {
            if (userAgentInfo.indexOf(Agents[v]) > 0) {
              flag = false;
              break;
            }
          }
          if(userAgentInfo.indexOf("Android") > 0 &&　userAgentInfo.indexOf("Mobile")<0){
            flag = true;
          }
          return flag;
        },
        goDifren() {
            let temp = location.hash;
            let hostName = location.origin;
          if(process.env.NODE_ENV === 'production' && !this.IsPC()){
              window.location.href=hostName+"/mobile"+temp
          }
        }
      },
      watch:{
          $route:function (n, o) {
            this.getKeyWord();
          }
      }
    }
</script>
<style lang="less">
  .web-inner{
    margin: 0 auto;
  }
  #app{
    height: 100%;
    min-height: 100%;
    *{
      box-sizing: border-box;
    }
    .el-input{
      width: 300px;
    }
  }
  @media screen and (min-width: 1400px) {
    .web-inner {
      width: 1162px;
    }
    .index-lunbotu,.big-link-image{
      height:386px ;
    }
  }
  @media screen and (max-width: 1400px) {
    .web-inner {
      width: 900px;
    }
    .index-lunbotu,.big-link-image{
      height:297px !important;
    }
  }

</style>
